﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SARControlLib;

namespace RadarSim.Pages
{

    /// <summary>
    /// Interaction logic for CWMain.xaml
    /// </summary>
    public partial class CWMain : PageBase
    {
        public CWMain()
        {
            InitializeComponent();
            //pdis.Loaded += new RoutedEventHandler(pdis_Loaded);   
            List<DataGridBean> l = new List<DataGridBean>();
            l.Add(new DataGridBean("a",true, "b", "c", "d"));
            l.Add(new DataGridBean("a", false, "f", "g", "h"));
            l.Add(new DataGridBean("a", true, "b", "c", "d"));
            l.Add(new DataGridBean("a", false, "f", "g", "h"));
            l.Add(new DataGridBean("a", true, "b", "c", "d"));
            l.Add(new DataGridBean("a", false, "f", "g", "h"));
            l.Add(new DataGridBean("a", true, "b", "c", "d"));
            l.Add(new DataGridBean("a", false, "f", "g", "h"));
            l.Add(new DataGridBean("a", true, "b", "c", "d"));
            l.Add(new DataGridBean("a", false, "f", "g", "h"));
            l.Add(new DataGridBean("a", true, "b", "c", "d"));
            l.Add(new DataGridBean("a", false, "f", "g", "h"));

            DataGridTemplateColumn tgtc = new DataGridTemplateColumn();
            tgtc.Header = "File";
            //tgtc.CellTemplate = (DataTemplate)Resources["dfd"];
            //StringBuilder CellTemp = new StringBuilder();
            //CellTemp.Append("<DataTemplate ");
            //CellTemp.Append("xmlns='http://schemas.microsoft.com/client/2007' ");
            //CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            ////Be sure to replace "YourNamespace" and "YourAssembly" with your app's
            ////actual namespace and assembly here
            //CellTemp.Append("xmlns:local = 'clr-namespace:SARControlLib");
            //CellTemp.Append(";assembly=SARControlLib'>");
            ////CellTemp.Append("<UserControl");
            ////CellTemp.Append("	xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'");
            ////CellTemp.Append("	xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'");
            ////CellTemp.Append("	xmlns:d='http://schemas.microsoft.com/expression/blend/2008'");
            ////CellTemp.Append("	xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006'");
            ////CellTemp.Append("	mc:Ignorable='d'");
            ////CellTemp.Append("	x:Class='SARControlLib.SARFileDialog'");
            ////CellTemp.Append("	Height='29'");
            ////CellTemp.Append("	x:Name='UserControl'");
            ////CellTemp.Append("	>");
            //CellTemp.Append("	<Grid >");
            //CellTemp.Append("		<TextBox x:Name='FilePath' IsReadOnly='True' Width='120' Background='Black'   Text='浏览文件' HorizontalAlignment='Left' VerticalAlignment='Center' Margin='5,3,0,3' Foreground='#FF44749F' FontFamily='Microsoft YaHei' Grid.ColumnSpan='2'/>");
            //CellTemp.Append("		<Button Margin='132.25,3,7.75,3' Width='60'  x:Name='Btn' Content='浏览' FontSize='{DynamicResource {x:Static SystemFonts.IconFontSizeKey}}' FontFamily='Microsoft YaHei' Foreground='#FF44749F' Background='#FFC6C6E4' d:LayoutOverrides='GridBox'  />");
            //CellTemp.Append("		</Grid>");
            //CellTemp.Append("</DataTemplate>");
            ////CellTemp.Append("</UserControl>");
            
            ////tgtc.CellTemplate = (DataTemplate)System.Windows.Markup.XamlReader.Load(CellTemp.ToString());
            ////tgtc.CellTemplate = (DataTemplate)System.Xaml.XamlReader.Load(CellTemp.ToString());
            
            
            ////tgtc.CellTemplate

            DataTemplate dt1 = new DataTemplate();
            FrameworkElementFactory fef1 = new FrameworkElementFactory(typeof(SARFileDialog));
            fef1.SetBinding(TextBlock.TextProperty, new Binding("Head0"));
            dt1.VisualTree = fef1;
            tgtc.CellTemplate = dt1;

            table1.SARnterDataGrid.Columns.Add(tgtc);

            //DataGridCheckBoxColumn dtc = new DataGridCheckBoxColumn();
            
            //dtc.Header = "check";
            //Binding b1 = new Binding();
            //b1.Path = new PropertyPath("Head1");
            //dtc.Binding = b1; 


            DataGridTextColumn dtc = new DataGridTextColumn();
            dtc.Header = "fff";
            Binding b1 = new Binding();
            b1.Path = new PropertyPath("Head1");
            dtc.Binding = b1;

            DataGridTextColumn dtc2 = new DataGridTextColumn();
            dtc2.Header = "fff";
            Binding b2 = new Binding();
            b2.Path = new PropertyPath("Head2");
            dtc2.Binding = b2;

            DataGridTextColumn dtc3 = new DataGridTextColumn();
            dtc3.Header = "fff";
            Binding b3 = new Binding();
            b3.Path = new PropertyPath("Head3");
            dtc3.Binding = b3;

            DataGridTextColumn dtc4 = new DataGridTextColumn();
            dtc4.Header = "fff";
            Binding b4 = new Binding();
            b4.Path = new PropertyPath("Head4");
            dtc4.Binding = b4;

            table1.SARnterDataGrid.Columns.Add(dtc);
            table1.SARnterDataGrid.Columns.Add(dtc2);
            table1.SARnterDataGrid.Columns.Add(dtc3);
            table1.SARnterDataGrid.Columns.Add(dtc4);
            
            
            table1.SARItemsSource = l;
			table1.DataGridTitle = "ff";


            List<DataGridBean> ll = table1.GetSelectedRows();
            
			
        }

//        void pdis_Loaded(object sender, RoutedEventArgs e)
//        {
//            pdis.SARBeamAngle = 60;
//            pdis.SARBeamDirect = 30;
//            pdis.SARBeamLight = 0.7;
//            pdis.SARBackImageOpacity = 0.05;
//            SARTarget newTarget = new SARTarget();
//            newTarget.SARDirect = 180;
//            newTarget.SARDistance = 60;
//            newTarget.SARObjectType = 2;
//            newTarget.SARAngle = 90;
//            newTarget.SARShowDirect = false;
//            pdis.SARAddTarget(newTarget);
//
//            newTarget = new SARTarget();
//            newTarget.SARDirect = 150;
//            newTarget.SARDistance = 40;
//            newTarget.SARObjectType = 1;
//            newTarget.SARAngle = 60;
//            pdis.SARAddTarget(newTarget);
//
//            newTarget = new SARTarget();
//            newTarget.SARDirect = 60;
//            newTarget.SARDistance = 60;
//            newTarget.SARObjectType = 0;
//            newTarget.SARAngle = 150;
//            pdis.SARAddTarget(newTarget);
//
//            pdis.SARSegmentNum1 = 12;
//            pdis.SARTextNum = 18;
//        }

        public bool AppConfigClick()
        {
            return true;
        }

        public bool ControlArgsClick()
        {
            return true;
        }

        public bool InitArgsClick()
        {
            return true;
        }

        public bool RealTimeInfoClick()
        {
            return true;
        }
    }
}
